//
//  PriceRecordViewController.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/11.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "PriceRecordViewController.h"
#import "PriceRecordTableViewCell.h"

@interface PriceRecordViewController ()<UITableViewDelegate,
    UITableViewDataSource>

@property (strong, nonatomic) UITableView *listTableView;

@end

@implementation PriceRecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"出价记录";
    
    [self initPageControl];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (void)initPageControl{
    
    [self.view addSubview:self.listTableView];
    [self.listTableView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.equalTo(@0);
    }];
    
    [self addTableHeaderView];
}

- (void)addTableHeaderView{
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
    headerView.backgroundColor = [UIColor whiteColor];
    self.listTableView.tableHeaderView = headerView;
    
    NSArray *titles = @[@"状态",@"竞买号",@"价格",@"时间"];
    for (int i=0; i<4; i++) {
        UILabel *label = [[UILabel alloc]init];
        label.font = [UIFont systemFontOfSize:16];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = titles[i];
        [headerView addSubview:label];
        [label makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(headerView.centerY);
            make.width.equalTo(@(SCREEN_WIDTH/4));
            make.height.equalTo(@30);
            make.left.equalTo(@(i*SCREEN_WIDTH/4));
        }];
    }
}
#pragma mark UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    PriceRecordTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PriceRecordTableViewCell" forIndexPath:indexPath];
    if (indexPath.row%2==0) {
        cell.backgroundColor = RGBCOLOR(246, 249, 251);
    }
    else{
        cell.backgroundColor = [UIColor whiteColor];
    }
    cell.priceLabel.text = @"￥12.00";
    cell.numberLabel.text = @"T4838";
    return cell;
}



#pragma mark getter
- (UITableView*)listTableView{
    if (_listTableView==nil) {
        _listTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _listTableView.delegate = self;
        _listTableView.dataSource = self;
        _listTableView.sectionFooterHeight = 0;
        _listTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _listTableView.backgroundColor = [UIColor clearColor];
        _listTableView.separatorStyle = UITableViewCellSeparatorStyleNone;        [_listTableView registerNib:[UINib nibWithNibName:@"PriceRecordTableViewCell" bundle:nil] forCellReuseIdentifier:@"PriceRecordTableViewCell"];
    }
    
    return _listTableView;
}


@end
